package com.wsoft.system.service.impl;

import com.wsoft.system.dto.Task;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @Author Zhang gukai
 * @Date 2024/11/11 10:16
 */
@Service("testTaskService")
public class TestTaskService {
    public List<Task> getTasks() {
        // 模拟从数据库获取任务列表
        return Arrays.asList(
                new Task("1", "Task 1", "Description 1", false),
                new Task("2", "Task 2", "Description 2", true),
                new Task("3", "Task 3", "Description 3", false),
                new Task("4", "Task 3", "Description 4", false)
        );
    }

    public int getCompletedTaskCount() {
        return (int) getTasks().stream().filter(Task::isCompleted).count();
    }

    public int getTaskCount(String name) {
        return (int) getTasks().stream().filter(e->e.getName().equals(name)).count();
    }
}
